const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
module.exports = {
  entry: './src/main.js',
  mode: 'development',
  devtool: 'cheap-module-source-map',
  devServer: {
    host: '0.0.0.0',
    port: 8080,
    compress: true,
    hot: true,
    hotOnly: true,
    open: true,
    historyApiFallback: true,
    proxy: {
      '/api/v1': 'http://localhost:3000',
      '/api/v2': {
        target: 'http://localhost:5000',
        secure: false, //默认情况下，将不接受在 HTTPS 上运行且证书无效的后端服务器
        changeOrigin: true, //默认情况下，代理时会保留主机头的来源，可以将 changeOrigin 设置为 true 以覆盖此行为。
        pathRewrite: {
          '^/api/v2': ''
        }
      }
    }
  },
  plugins: [
      new ReactRefreshWebpackPlugin()
  ]
}